﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using InfoSoftGlobal;
using System.Text;
using Oracle.DataAccess.Client;
using System.Configuration;
using System.Data;
using Entidades.Solicitud;
using Entidades.Graficas;

using Control.Catalogo;
using Entidades.Consultas.Personalizadas;

namespace SICOIA
{
    public partial class Login : System.Web.UI.Page
    {
        private CtrlSolicitudTrabajosRealizar ctrl = null;

        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Cache.SetNoServerCaching();
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.Cache.SetNoStore();
            Response.Cache.SetExpires(new DateTime(1900, 1, 1, 0, 0, 0, 0));

            ctrl = new CtrlSolicitudTrabajosRealizar();
            CargarPrioritarias();
        }

        #region Grafica PROGRAMADAS
        /// <summary>
        /// getObrasJefeSector
        /// </summary>
        /// <returns></returns>
        /// Grafica Principal
        public string ObtenerGraficaUno()
        {
            string xmlData =
                "<chart pieRadius='80' legendNumColumns='2' labelDistance='0'  bgColor='#FFFFFF' showLabels='1' showValues='1' showLegend='1' legendPosition='BOTTOM'  " +
                "  basefontcolor='#000000' basefontsize='10' showpercentvalues='1' startingangle='300' animation='1'> "+
                "<set value='2'  color='##3ADF00'   link='javascript:mensaje(&quot;REQUI&quot;);'   label='Requisitadas' color='005C8E'/>" +
                "<set value='32' color='#F4FA58'    link='javascript:mensaje(&quot;SIN_SOL&quot;);' label='Sin Solicitar' color='00759B'/>" +
                "<set value='12' color='#FACC2E'    link='javascript:mensaje(&quot;SIN_PLA&quot;);' label='Sin Planos' color='0296D2'/>" +
                "<set value='20' label='Validación' link='javascript:mensaje(&quot;VALIDA&quot;);' color='40C7F9'/>" +
                "</chart>";
            
            return FusionCharts.RenderChartHTML("/FusionCharts/Pie2D.swf", "", xmlData.ToString(), "Obras", "500", "250", false);
        }

        #region Detalles
        // Requisitadas
            public string ObtenerGraficaDetalleUno()
        {
            string xmlData =
            "<chart bgColor='#FFFFFF' showBorder='0' imageSave='1' numberPrefix='' formatNumber='1' formatNumberScale ='0' > " +
            "<set label='Sin Iniciar' value='24' /> " +
            "<set label='Proceso' value='67' /> " +
            "<set label='Atendidas' value='20' /> " +
            "</chart> ";

            return FusionCharts.RenderChartHTML("/FusionCharts/Column3D.swf", "", xmlData.ToString(), "Obras", "250", "250", false);
        }
        // Sin Solicitar
            public string ObtenerGraficaDetalleDos()
            {
                string xmlData =
                "<chart bgColor='#FFFFFF' showBorder='0' imageSave='1' numberPrefix='' formatNumber='1' formatNumberScale ='0' > " +
                "<set label='Sin Iniciar' value='10' /> " +
                "<set label='Proceso' value='23' /> " +
                "<set label='Atendidas' value='1200' /> " +
                "</chart> ";

                return FusionCharts.RenderChartHTML("/FusionCharts/Column3D.swf", "", xmlData.ToString(), "Obras", "250", "250", false);
            }
        // Sin Planos
            public string ObtenerGraficaDetalleTres()
            {
                string xmlData =
                "<chart bgColor='#FFFFFF' showBorder='0' imageSave='1' numberPrefix='' formatNumber='1' formatNumberScale ='0' > " +
                "<set label='Sin Iniciar' value='30' /> " +
                "<set label='Proceso' value='3' /> " +
                "<set label='Atendidas' value='50' /> " +
                "</chart> ";

                return FusionCharts.RenderChartHTML("/FusionCharts/Column3D.swf", "", xmlData.ToString(), "Obras", "250", "250", false);
            }
        // En validacion
            public string ObtenerGraficaDetalleCuatro()
            {
                string xmlData =
                "<chart bgColor='#FFFFFF' showBorder='0' imageSave='1' numberPrefix='' formatNumber='1' formatNumberScale ='0' > " +
                "<set label='Sin Iniciar' value='34' /> " +
                "<set label='Proceso' value='33' /> " +
                "<set label='Atendidas' value='80' /> " +
                "</chart> ";

                return FusionCharts.RenderChartHTML("/FusionCharts/Column3D.swf", "", xmlData.ToString(), "Obras", "250", "250", false);
            }
        #endregion
        #endregion
        #region GridPrioritarias
            public void CargarPrioritarias()
            {
                List<EntObraConDetalle> lista =
                ctrl.ObtenerPrioritarias("","");

                grdSoliciudes.DataSource = lista;
                grdSoliciudes.DataBind();

                Session["ListadoSolicitudes"] = lista;
            }
        #endregion

            #region Eventos Grid Solicitudes

            protected void grdSoliciudes_PageIndexChanging(object sender, GridViewPageEventArgs e)
            {
                GridView gv = (GridView)sender;
                gv.PageIndex = e.NewPageIndex;

                grdSoliciudes.DataSource = (List<Entidades.General.IEntidad>)Session["ListadoSolicitudes"];
                grdSoliciudes.DataBind();
            }

            protected void grdSoliciudes_RowCommand(object sender, GridViewCommandEventArgs e)
            {
                if (e.CommandName == "Editar")
                    Response.Redirect("ProxyUserControls.aspx?Url=Solicitud&accion=editar&IdSolicitud=" + e.CommandArgument.ToString(), true);
            }

            #endregion
    }
}